<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/inc/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
    <link rel="stylesheet" href="${path }/admin/css/pintuer.css"/>
    <link rel="stylesheet" href="${path }/admin/css/admin.css"/>
    
    <link rel="stylesheet" href="${path }/admin/css/inputPage.css"/>
    
    
    <script src="${path }/public/js/jquery-1.8.2.min.js"></script>
    <script src="${path }/admin/js/pintuer.js"></script>
<script src="${path}/public/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script type="text/javascript" src="${path}/public/layer/layer.js"></script>
</head>
<body>
<form method="post" action="${path}/admin/activity/index.do" id="form">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 活动管理</strong></div>
    <div class="padding border-bottom">
      <ul class="search">
        <li>
        <input type="text" name="name" class="input" value="${name}" placeholder="活动名"/>
        </li>
        <li>
        	 <input type="text" name="startTimeStr" class="txtSearch" value="${startTimeStr}" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" style="width: 160px;height: 40px;border-radius: 3px;" placeholder="开始时间">&nbsp;
            	至
        	 <input type="text" name="endTimeStr" class="txtSearch" value="${endTimeStr}" onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" style="width: 160px;height: 40px;border-radius: 3px;"  placeholder="结束时间">&nbsp;
        </li>
        <li>
        <select name="status" class="input" >
          <option value="">请选择状态</option>
          
          <option value="0" <c:if test="${status eq '0' }">selected="selected"</c:if>>尚未开始</option>
          <option value="1" <c:if test="${status eq '1' }">selected="selected"</c:if>>正在进行</option>
          <option value="2" <c:if test="${status eq '2' }">selected="selected"</c:if>>手动结束</option>
          <option value="3" <c:if test="${status eq '3' }">selected="selected"</c:if>>已结束</option>
          
        </select>
        
        </li>
        <li>
          <a class="button border-green" href="javascript:;" onclick="submitform();" ><span class="icon-search"></span> 查询</a>
        </li>
        
        <li>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <a class="button border-green" href="${path}/admin/activity/toupdateoradd.do" onclick="submitform();" ><span class="icon-edit"></span> 添加</a>
        </li>
      </ul>
    </div>
    <table class="table table-hover text-center">
      <tr>
        <th width="5%">序号</th>       
        <th width="15%">名称</th>       
        <th width="10%">报名开始时间</th>       
        <th width="10%">报名结束时间</th>       
        <th width="10%">开始时间</th>       
        <th width="10%">结束时间</th>       
        <th width="5%">人数上限</th>       
        <th width="10%">活动状态</th>       
        <th width="10%">创建时间</th>       
        <th width="15%">操作</th>       
      </tr>      
      <c:forEach items="${page.list}" var="activity" >
        <tr>
          <td>${activity.index}</td>
          <td>${activity.name}</td>
          <td>${activity.enStartTimeStr}</td>
          <td>${activity.enEndTimeStr}</td>
          <td>${activity.startTimeStr}</td>
          <td>${activity.endTimeStr}</td>
          <td>${activity.maxCount}</td>
          <td>
              <c:if test="${activity.status == 0}">
                尚未开始
              </c:if>
              <c:if test="${activity.status == 1}">
                正在进行
              </c:if>
              <c:if test="${activity.status == 2}">
                手动结束
              </c:if>
              <c:if test="${activity.status == 3}">
                已结束
              </c:if>
          </td>
          <td>${activity.createTimeStr}</td>
          <td>
          
          <%--<c:if test="${activity.status=='尚未开始'}">--%>
          <c:if test="${activity.status==0}">
	          <div class="button-group">
	          <a class="button border-red" href="${path}/admin/activity/updateAct.do?id=${activity.id}" >修改</a><span>&nbsp;&nbsp;</span>
	          </div>
	          
	          <div class="button-group"> 
	          <a class="button border-red" href="" onclick="stopAct(${activity.id})" >手动终止</a><span>&nbsp;&nbsp;</span>
	          </div>
          </c:if>
          <div class="button-group"> 
          <a class="button border-red" href="${path}/admin/activity/infor.do?id=${activity.id}" >详情</a>&nbsp;&nbsp; 
          </div>
          <%--<c:if test="${activity.status=='已结束'||activity.status=='手动结束'}">--%>
          <c:if test="${activity.status==2 || activity.status==3}">
	          <div class="button-group">
	          <a class="button border-red" href="${path}/admin/activity/rePublishAct.do?id=${activity.id}" >再次发起</a> 
	          </div>
          </c:if>
          <%--<c:if test="${activity.status=='删除'}">--%>
	          <div class="button-group"> 
	          <a class="button border-red" href="" onclick="deleteAct(${activity.id})">删除</a> 
	          </div>
          <%--</c:if>--%>
          
          </td>
        </tr>
      </c:forEach>
      <tr>
        <td colspan="10">
			<jsp:include page="/WEB-INF/inc/page.jsp" flush="true"/>		
		</td>
      </tr>
    </table>
  </div>
</form>
<script type="text/javascript">


function gotopage(url){
	window.location.href=url;
}

function submitform(){
	$("#form").submit();
}

function rePublishAct(id){
	
	alert(id)
window.location.href="${path}/admin/activity/rePublishAct.do?id="+id;
}

function deleteAct(id){
	if(confirm("您确定要删除该活动吗?")){
		var param = {};
		param.id=id;
		$.ajax({
			type : "post",
			url :'${path}/admin/activity/del.do',
			data : param,
			dataType : 'json',
			success : function(datas) {
				if(datas==1){
					$("#form").submit();
				}else{
					alert("删除失败");
				}
			}
		});
	}
}

function stopAct(id){
	if(confirm("您确定要结束该活动吗?")){
		var param = {};
		param.id=id;
		param.status="手动结束";
		$.ajax({
			type : "post",
			url :'${path}/admin/activity/updateStatus.do',
			data : param,
			dataType : 'json',
			success : function(datas) {
				submitform();
			}
		});
	}
}


</script>
</body></html>